package org.uim.cricket.analyzer.parsers;

import org.uim.cricket.analyzer.parsers.match.CricketMatchParsable;

public class BeanScoreCardFactory extends AbstractScoreCardFactory {

	private FetchScoreCardParserBeans beansScoreCard = null;
	
	public BeanScoreCardFactory(String beanFile) {
		this.beansScoreCard = new FetchScoreCardParserBeans(beanFile);
		this.beansScoreCard.loadBeans();
	}
	
	@Override
	public CricketMatchParsable createScoreCardParser(String type) throws Exception {
		CricketMatchParsable obj = this.beansScoreCard.fetchScoreCardBean(type);
		if (obj == null) {
			throw new Exception("There is no bean to be found by name '" + type + "'!");
		}
		return obj;
	}

}
